//
//  SideBarViewController.m
//  老司机发车了
//
//  Created by 斌 on 16/8/5.
//  Copyright © 2016年 斌. All rights reserved.
//

#import "SideBarViewController.h"
#import "RegisterViewController.h"
#import "LoginViewController.h"

@interface SideBarViewController ()
// 点击登陆的头像
@property (strong, nonatomic) UIImageView *img;
// 登陆按钮
@property (strong, nonatomic) UIButton *loginButton;
// 忘记密码按钮
@property (strong, nonatomic) UIButton *forget;
// 注册按钮
@property (strong, nonatomic) UIButton *registerBtn;



@end

@implementation SideBarViewController




- (void)viewDidLoad {
    [super viewDidLoad];
    // 背景
    UIImageView *backimg = [[UIImageView alloc] initWithFrame:self.view.bounds];
    backimg.image = [UIImage imageNamed:@"登陆界面.jpg"];
    [self.view addSubview:backimg];
    // 登录头像
    self.img = [[UIImageView alloc] initWithFrame:CGRectMake((0.7 * kScreenWidth - 80) / 2, 50, 80, 80)];
    self.img.image = [UIImage imageNamed:@"登录.jpg"];
    self.img.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(loginAction)];
    [self.img addGestureRecognizer:tap];
    [self.view addSubview:_img];
    // 登录按钮
    self.loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.loginButton setTitle:@"点击登录" forState:UIControlStateNormal];
    [self.loginButton addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    self.loginButton.frame = CGRectMake(0, 0, 100, 30);
    self.loginButton.centerX = _img.centerX;
    self.loginButton.ownY = _img.ownY + _img.ownHeight;
    [self.view addSubview:_loginButton];
    // 注册按钮
    self.registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.registerBtn setTitle:@"注册" forState:UIControlStateNormal];
    [self.registerBtn addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    self.registerBtn.frame = CGRectMake(30, _loginButton.endY + 30, 100, 30);
    [self.view addSubview:_registerBtn];

    // 忘记密码按钮
    self.forget = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.forget setTitle:@"忘记密码" forState:UIControlStateNormal];
    [self.forget addTarget:self action:@selector(forgetAction) forControlEvents:UIControlEventTouchUpInside];
    self.forget.frame = CGRectMake(0, _registerBtn.ownY, 100, 30);
    self.forget.endX = 0.7 * kScreenWidth - 30;
    [self.view addSubview:_forget];


    self.view.backgroundColor = [UIColor yellowColor];
    
    
    
    
}

// 登陆方法
- (void)loginAction {
    
    LoginViewController *loginVC = [[LoginViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVC];
    nav.navigationBar.translucent = NO;
    
    [self presentViewController:nav animated:YES completion:nil];
    
}


// 注册按钮方法
- (void)registerAction {
    RegisterViewController *registerVC = [[RegisterViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:registerVC];
    nav.navigationBar.translucent = NO;
    [self presentViewController:nav animated:YES completion:nil];
    
    
    
}

// 忘记密码按钮方法
- (void)forgetAction {
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
